package com.cssl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cssl.pojo.TbMember;
import com.cssl.service.TbMemberService;
import com.cssl.mapper.TbMemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author he
* @description 针对表【tb_member】的数据库操作Service实现
* @createDate 2024-08-06 20:35:16
*/
@Service
public class TbMemberServiceImpl extends ServiceImpl<TbMemberMapper, TbMember>
    implements TbMemberService{

    @Autowired
    private TbMemberMapper tbMemberMapper;

    @Override
    public Page<TbMember> pageMember(Integer pageNum, Integer pageSize,String username) {
        Page<TbMember> page = new Page<>();
        page.setCurrent(pageNum);
        page.setSize(pageSize);
        LambdaQueryWrapper<TbMember> queryWrapper = new LambdaQueryWrapper<>();
        //根据id升序排列
        queryWrapper.orderByAsc(TbMember::getId);

        //username不为空 添加模糊查询添加
        if (username != null && !"".equals(username)) {
            queryWrapper.like(TbMember::getUsername, username);
        }

        return tbMemberMapper.selectPage(page, queryWrapper);
    }
}




